package com.lxm.ymcc.web.controller;
import com.lxm.ymcc.domain.CourseDoc;
import com.lxm.ymcc.dto.SearchDto;
import com.lxm.ymcc.result.JSONResult;
import com.lxm.ymcc.result.PageList;
import com.lxm.ymcc.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private ISearchService searchService;
    @PostMapping("/save")
    public JSONResult save(@RequestBody CourseDoc doc){
        searchService.save(doc);
        return JSONResult.success();
    }
    @PostMapping("/del/{id}")
    public JSONResult del(@PathVariable("id") Long id){
        searchService.del(id);
        return JSONResult.success();
    }


    @PostMapping("/course")
    public JSONResult searchCourse(@RequestBody SearchDto dto){
        PageList<CourseDoc> pageList = searchService.searchCourse(dto);
        return JSONResult.success(pageList);
    }
}

